#include "RenzoAnimatorKeyFrame.h"

namespace Renzo
{
AnimatorKeyFrame::AnimatorKeyFrame(void)
{
	curFrame = 0;
	curTimeElapsed = 0;
	frameTimeElapsed = 100;
}

AnimatorKeyFrame::~AnimatorKeyFrame(void)
{
}

void AnimatorKeyFrame::initialize(int curFrame, int nbFrames, int nbFacesPerFrame, int nbVerticesPerFrame) {
	this->curFrame = curFrame;
	this->nbFrames = nbFrames;
	this->nbFacesPerFrame = nbFacesPerFrame;
	this->nbVerticesPerFrame = nbVerticesPerFrame;
}

void AnimatorKeyFrame::nextFrame() {
	curFrame = (curFrame + 1) % nbFrames;
}

void AnimatorKeyFrame::update(int delta) {
	curTimeElapsed += delta;
	while (curTimeElapsed >= frameTimeElapsed) {
		nextFrame();
		curTimeElapsed -= frameTimeElapsed;
	}
}

int AnimatorKeyFrame::getCurrentFrame() const {
	return curFrame;
}

int AnimatorKeyFrame::getFrameCount() const {
	return nbFrames;
}

int AnimatorKeyFrame::getFacesPerFrame() const {
	return nbFacesPerFrame;
}

int AnimatorKeyFrame::getVerticesPerFrame() const {
	return nbVerticesPerFrame;
}

}

